package cn.lg.soar.system.auth.entity;

import cn.lg.soar.common.util.trans.annotations.Translate;
import cn.lg.soar.database.base.entity.IBaseEntity;
import cn.lg.soar.system.handler.AccountBindTypeTranslateHandler;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * 账号绑定
 * @author luguoxiang
 * @date 2021/9/12
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Getter
@Setter
@TableName("lg_sys_account_bind")
public class AccountBind {

    @TableId
    private Long id;

    @ApiModelProperty("绑定用户id")
    private Long userId;

    @Translate(AccountBindTypeTranslateHandler.class)
    @NotNull(message = "账号类型不能为空(根据系统定义，如：1手机，2邮箱，3微信小程序，4微信公众号)")
    @ApiModelProperty("账号类型")
    private Integer accountType;

    @NotBlank(message = "账号不能为空（账号类型和账号组成唯一值）")
    @ApiModelProperty("账号")
    private String account;

    @ApiModelProperty("最后登录时间")
    private LocalDateTime lastLoginDate;

    @ApiModelProperty("登录次数(成功)")
    private Integer loginCount;

    @ApiModelProperty("联盟id")
    private String uniId;

    @ApiModelProperty("备注")
    private String remark;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @ApiModelProperty(value = "创建时间")
    @TableField(value = IBaseEntity.CREATE_TIME, fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    protected LocalDateTime createTime;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @ApiModelProperty(value = "更新时间")
    @TableField(value = IBaseEntity.UPDATE_TIME, fill = FieldFill.INSERT_UPDATE)
    protected LocalDateTime updateTime;

}
